package org.example.ch02.p03;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextLine()){
            int n= scanner.nextInt();
            String[][] table= generateTable(n);
            printTable(table);
            System.out.println(Arrays.deepToString(table));
        }
        scanner.close();
    }
    private static String[][] generateTable(int n){
        String[][] table = new String[n][];
        for (int i = 1; i <=n ; i++) {
            String[]row= new String[i];
            for (int j = 1; j <=i ; j++) {
                row[j-1]=  i+"*"+j+"="+(i*j);
            }
            table[i-1]= row;
        }
        return table;
    }
    private static void printTable(String[][] table){
        for (String[] row:table){
            StringBuilder sb= new StringBuilder();
            for (int j=0;j<row.length;j++){
                sb.append(row[j]);
                if (j!=row.length-1){
                    int spaces=7-row[j].length();
                    sb.append(" ".repeat(Math.max(0,spaces)));
                }
            }
            System.out.println(sb.toString());
        }
    }
}
